Gigi and Code Generation

The phase labeled Gigi (Gnat to Gnu) interfaces the front-end with the GCC code generator. Gigi traverses the decorated and expanded AST, in order to build the corresponding GCC tree, which is then input to the code generator proper. More precisely, the activities of GCC tree construction and code generation are interspersed, so that after each code generation activity, the GCC tree fragment can be discarded. At no time is a full tree built (there is no such notion in GCC). This is in line with the one-pass model of compilation used for C, and is memory-efficient.

In order to bridge the semantic gap between Ada and C, several code generation routines in GCC have been extended, and others added, so that the burden of translation is also assumed by Gigi and GCC whenever it would be awkward or inefficient to perform the expansion in the front-end. For example, there are code generation actions for exceptions, for variant parts, and for access to unconstrained types. As a matter of GCC policy, the code generator is extended only when the extension is likely to be of benefit to more than one language.